<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1">
<input type="text" id="i2">
<input type="button" value="加" onclick="add()">
<input type="button" value="减" onclick="subtract()">
<input type="button" value="乘" onclick="multiplication()">
<input type="button" value="除" onclick="division()">
<div></div>

<script>
    let i1=document.querySelector("#i1");
    let i2=document.querySelector("#i2");
    let result=document.querySelector("div");

    function add() {
        if (isNaN(i.value)||isNaN(d.value)){
            result.innerText="输入错误"
        }else{
            result.innerText=i1.value*1+i2.value*1;
        }
    }
    function subtract() {
        if (isNaN(i.value)||isNaN(d.value)){
            result.innerText="输入错误"
        }else{
            result.innerText=i1.value-i2.value;
        }
    }
    function multiplication() {
        if (isNaN(i.value)||isNaN(d.value)){
            result.innerText="输入错误"
        }else{
            result.innerText=i1.value*i2.value;
        }
    }
    function division() {
        if (isNaN(i.value)||isNaN(d.value)){
            result.innerText="输入错误"
        }else{
            result.innerText=i1.value/i2.value;
        }
    }
</script>
</body>
</html>